/*
 * symedge.cpp
 *
 *  Created on: 16/11/2011
 *      Author: Aeradon
 */

#include "../include/symedge.hpp"

#ifdef _DEBUG
	#include <cstdio>
#endif

SymEdge::SymEdge(Vertex* v, Edge* e) :
	isBoundary(false),
	isConstrained(false),
	vecIndex(0),
	mark(0),
	vertex(v),
	edge(e),
	face(nullptr),
	normal(0,0),
	next(nullptr),
	rotate(nullptr),
	symEdge(nullptr)
{

}

void SymEdge::resetSymEdge(V* v, E* e)
{
	//isBoundary = false;
	//isConstrained = false;
	//mark = 0;
	vertex = v;
	edge = e;
	face = nullptr;
	normal.setXY(0,0);
	next = nullptr;
	rotate = nullptr;
	//symEdge = nullptr;
}

SymEdge::~SymEdge()
{
#ifdef _DEBUG
	printf("\nDELETANDO SYMEDGE!\n");
	fflush(stdout);
#endif
}

void SymEdge::setConstrained(const std::list<C*>& l_c)
{
	isConstrained = true;
	l_constraint = l_c;
}

void SymEdge::setConstrained(C* c)
{
	isConstrained = true;
	l_constraint.push_back(c);
}

void SymEdge::removeConstraint(C* c)
{
	l_constraint.remove(c);

	if (l_constraint.empty())
	{
		vertex->isConstrained = false;
		nxt()->vtx()->isConstrained = false;

		isConstrained = false;
	}
}


bool SymEdge::hasConstraint(C* c)
{
	for (std::list<C*>::iterator itr = l_constraint.begin();
		 itr != l_constraint.end();
		 ++itr)
	{
		if ( (*itr)->id == c->id) return true;
	}

	return false;
}



